import prisma from '@/lib/prisma';

export async function getComfyUIApiUrl() {
  const config = await prisma.config.findUnique({
    where: { key: 'COMFYUI_API_URL' },
  });
  return config ? config.value : process.env.COMFYUI_API_URL;
}

export async function setComfyUIApiUrl(url) {
  await prisma.config.upsert({
    where: { key: 'COMFYUI_API_URL' },
    update: { value: url },
    create: { key: 'COMFYUI_API_URL', value: url },
  });
}